sysroot: Add a flag to suppress post-deploy cleanup
authorColin Walters <walters@verbum.org>
Mon, 29 Aug 2016 02:22:59 +0000 (22:22 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Mon, 29 Aug 2016 07:45:24 +0000 (07:45 +0000)
I noticed seeing the output of `prune` twice in rpm-ostree, and had
always wondered why.  When reading the rpm-ostree code to fix
something else, reasons, I noticed the reason - we were pruning once
here, and then once after rpm-ostree regenerates its "base" refs.

There's no reason to clean twice, so let's add a flag so rpm-ostree
can suppress doing it inside libostree.

Closes: #474
Approved by: giuseppe

src/libostree/ostree-sysroot.c
src/libostree/ostree-sysroot.h

index 227fdd24675640522faef2ce540588a185c11fc5..82f864cb5a2ab1ed9062ba0eb28ac2d9f7b45c56 100644 (file)
@@ -1540,6 +1540,7 @@ ostree_sysroot_simple_write_deployment (OstreeSysroot      *sysroot,
   OstreeDeployment *booted_deployment = NULL;
   g_autoptr(GPtrArray) deployments = NULL;
   g_autoptr(GPtrArray) new_deployments = g_ptr_array_new_with_free_func (g_object_unref);
+  const gboolean postclean = (flags & OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN) == 0;
   gboolean retain = (flags & OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN) > 0;
   const gboolean make_default = !((flags & OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NOT_DEFAULT) > 0);
   gboolean added_new = FALSE;
@@ -1593,8 +1594,11 @@ ostree_sysroot_simple_write_deployment (OstreeSysroot      *sysroot,
   if (!ostree_sysroot_write_deployments (sysroot, new_deployments, cancellable, error))
     goto out;
 
-  if (!ostree_sysroot_cleanup (sysroot, cancellable, error))
-    goto out;
+  if (postclean)
+    {
+      if (!ostree_sysroot_cleanup (sysroot, cancellable, error))
+        goto out;
+    }
 
   ret = TRUE;
  out:
index 1e60ddbe452360bf94d96cf0405fe992643f3135..1e98cc10e338229fe6200995ea993703b93e506c 100644 (file)
@@ -182,7 +182,8 @@ GKeyFile *ostree_sysroot_origin_new_from_refspec (OstreeSysroot      *self,
 typedef enum {
   OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NONE = 0,
   OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN = (1 << 0),
-  OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NOT_DEFAULT = (1 << 1)
+  OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NOT_DEFAULT = (1 << 1),
+  OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN = (1 << 2),
 } OstreeSysrootSimpleWriteDeploymentFlags;
 
 _OSTREE_PUBLIC